package com.hotacorp.opencloud.jobservice.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hotacorp.opencloud.common.mybatisplus.PageData;
import com.hotacorp.opencloud.common.mybatisplus.Query;

import com.hotacorp.opencloud.jobservice.dao.ScheduleJobLogDao;
import com.hotacorp.opencloud.jobservice.entity.ScheduleJobLogEntity;
import com.hotacorp.opencloud.jobservice.service.ScheduleJobLogService;

/**
 * 定时任务日志接口实现
 * @author lwg
 *
 */
@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogDao, ScheduleJobLogEntity> implements ScheduleJobLogService {

    @Override
    public PageData queryPage(Map<String, Object> params) {
    	QueryWrapper<ScheduleJobLogEntity> query= new QueryWrapper<ScheduleJobLogEntity>();
    	if (StringUtils.isNotBlank((String)params.get("jobId"))) query.eq("job_id", Long.parseLong(params.get("jobId").toString()));
    	query.orderByDesc("create_time");
        IPage<ScheduleJobLogEntity> page = this.page(
                new Query<ScheduleJobLogEntity>().getPage(params),
                query
        );

        return new PageData(page);
    }

}